package api

import (
	"gitee.com/zatto/maudit/apps/audit"
	"github.com/emicklei/go-restful/v3"
	"github.com/infraboard/mcube/exception"
	"github.com/infraboard/mcube/http/response"
)

func (h *handler) QueryAuditLog(r *restful.Request, w *restful.Response) {
	in := audit.NewQueryAuditLogRequest()
	err := r.ReadEntity(in)
	if err != nil {
		response.Failed(w, exception.NewBadRequest("请求参数异常"))
		return
	}

	als, err := h.service.QueryAuditLog(r.Request.Context(), in)
	if err != nil {
		response.Failed(w, exception.NewInternalServerError("服务异常"))
		return
	}

	w.WriteEntity(als)
}
